<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<div class="panel" defH="50">
		<h1>考勤数据查看</h1>
		<div>
			类别:
			<input type="radio" checked="checked" name="lynn-kq-type" value="1"/>查看全部
			<input type="radio" name="lynn-kq-type" value="2"/>按部门查看
			<input type="radio" name="lynn-kq-type" value="3"/>按人员查看
			<a id="lynn-export-monthReport-01-aaa" href=""></a>
			<div class="button" style="float: right;"><div class="buttonContent" id="lynn-export-monthReport-01"><button>导出考勤报表</button></div></div>
			<br/>
			时间:
			<input type="radio" checked="checked" name="lynn-kq-time" value="1"/>本月
			<input type="radio" name="lynn-kq-time" value="2"/>上月
			<input type="radio" name="lynn-kq-time" value="3"/>自定义
			<input type="text" class="date" name="lynn-monthReport-date" flag="st"/> 至  <input type="text" class="date" name="lynn-monthReport-date" flag="et"/>
			<input type="button" name="lynn-monthReport-submit" value="提交" />
		</div>
</div>

<div id="lynn-monthReport-content-01" style="float:left;   overflow:auto;border-width: 2px;border-style: groove;border-color: blue; width: 180px;height:380px;margin-top: 15px;margin-left: 10px;padding-left: 5px;padding-top: 5px;">

</div>
<div id="lynn-monthReport-content-02" style="display: block;margin-top:15px;margin-right:10px;   overflow:auto;border-width: 2px;border-style: groove;border-color: blue;height: 385px; ">
	
</div>
<script>
var ssType = "1";//选取的类型
var ssTime = "1";//选取的时间跨度
var st = "";//选取的开始时间
var et = "";//选取的结束时间
var flag00 = "";

var showEmpTree = function (cb) {
	$.ajax({
		  url: "<%=basePath%>emp!showTree.do"
		}).done(function ( data ) {
			$("#lynn-monthReport-content-01").html(data);
			lynnInitTree();
			if(typeof cb != "undefined")
			cb();
		});
}

var showDepTree = function (cb) {
	$.ajax({
		  url: "<%=basePath%>emp!showTree.do?flag=dep"
		}).done(function ( data ) {
			$("#lynn-monthReport-content-01").html(data);
			lynnInitTree();
			if(typeof cb != "undefined")
			cb();
		});
	
}

$("input[name=lynn-kq-type]").click(function (event) {
	var v = $(event.currentTarget).attr("value");
	ssType = v;
	if(v == "1") {
		//查看所有
		showAll();
		
	} else if(v == "2") {
		//部门
		dep();
		
	} else if(v == "3") {
		//人员
		emp();
		
	}
});
var showAll = function () {
	showEmpTree();
	$("#lynn-monthReport-content-02").html("<p style='padding-left:15px;padding-top:5px;font-size:18px;color:blue;'>请选择日期并单击提交</p>");
}
var dep = function () {
	showDepTree(function () {
		$.ajax({
			  url: "<%=basePath%>module/attendance/byMD.jsp?flag=dep"
			}).done(function ( data ) {
				$("#lynn-monthReport-content-02").html(data);
			});
	});
}

var emp = function () {
	showEmpTree(function () {
		$.ajax({
			  url: "<%=basePath%>module/attendance/byMD.jsp?flag=emp"
			}).done(function ( data ) {
				$("#lynn-monthReport-content-02").html(data);
			});
	});
}

$("input[name=lynn-kq-time]").click(function(event){
	var v = $(event.currentTarget).attr("value");
	ssTime = v;
	/*
	if(v == "1") {
	//本月
		ssTime = "1";
	} else if(v == "2") {
	//上月
		ssTime = "2";
	} else if(v == "3") {
	//自定义
		ssTime = "3";
	}*/
});

$("input[name=lynn-monthReport-submit]").click(function(event){
	var a = [];
	if(typeof lynn.getSelectDepList != "undefined"){
		a = lynn.getSelectDepList();
	}
	$("input[name=lynn-monthReport-date]").each(function(i){
		var f = $(this).attr("flag");
		var v = $(this).attr("value");
		if(f == "st") {
			st = v;
		} else if(f == "et") {
			et = v;
		}
	});
	RemoteService.monthReport(Math.random()+"",ssType,ssTime,st,et,a,function (data) {
		flag00 = data;

		$.ajax({
			url:"<%=basePath%>statistics!monthReport.do?flag="+flag00
		}).done(function(data){
			$("#lynn-monthReport-content-02").html(data);
		});
	});
});

$("div#lynn-export-monthReport-01").click(function(event){
	var a = [];
	if(typeof lynn.getSelectDepList != "undefined"){
		a = lynn.getSelectDepList();
	}
	$("input[name=lynn-monthReport-date]").each(function(i){
		var f = $(this).attr("flag");
		var v = $(this).attr("value");
		if(f == "st") {
			st = v;
		} else if(f == "et") {
			et = v;
		}
	});
	RemoteService.monthReport(Math.random()+"",ssType,ssTime,st,et,a,function (data) {
		flag00 = data;
		var href = "<%=basePath%>export!exportMonthReport.do?flag="+flag00;
		$("a#lynn-export-monthReport-01-aaa").attr("href",href);
		$("a#lynn-export-monthReport-01-aaa").get(0).click();
		//$("a#lynn-export-monthReport-01-aaa").trigger("click");
	});
});

showEmpTree();
</script>